package dp;

import java.util.Scanner;

import static sun.swing.MenuItemLayoutHelper.max;

public class Test01 {
    private static int dp[][]  = new int[101][101];

    private static void printNums(int nums[][]){
        for (int i = 0; i < nums.length; i++) {
            for (int j = 0; j <= i; j++) {
                System.out.print(nums[i][j] + " ");
            }
            System.out.println();
        }
    }
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[][] nums = new int[n][n];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j <= i; j++) {
                nums[i][j] = scanner.nextInt();
            }
        }
        dp[0][0] = nums[0][0]; // 假设dp[i][j] 为处理 a[i][j] 后能达到的最大值。
        for (int i = n - 1; i >= 1; i--) {
            for (int j = 0; j <= i; j++) {
                dp[i][j] = max(dp[i + 1][j] + nums[i][j] ,dp[i+1][j+1] + nums[i][j]);
            }
        }
    }
}
